import {Component, OnInit} from '@angular/core';

@Component({
    selector: 'app-globe',
    templateUrl: './globe.component.html',
    styleUrls: ['./globe.component.less']
})
export class GlobeComponent implements OnInit {
    itemsXNum = 9; // x轴数量
    itemsYNum = 9; // y轴数量
    itemsX = [];
    itemsY = [];
    constructor() {
    }

    ngOnInit() {
        this.initItems(this.itemsXNum, this.itemsYNum);
    }
    initItems(x: any, y: any) {
        let obj = {};
        const rotateX = 180 / parseInt(x);
        const rotateY = 180 / parseInt(y);
        this.itemsX = [];
        this.itemsY = [];
        const centerX = Math.ceil(x / 2);
        for (let i = 0; i < x; i++) {
            obj = {
                index: i,
                rotateZ: 100 - (20 * (i + 1))
            };
            switch (i) {
                case 0:
                case 8:
                    obj['scale'] = 0.46;
                    break;
                case 1:
                case 7:
                    obj['scale'] = 0.75;
                    break;
                case 2:
                case 6:
                    obj['scale'] = 0.9;
                    break;
                case 3:
                case 5:
                    obj['scale'] = 0.98;
                    break;
                case 4:
                    obj['scale'] = 1;
                    break;
            }
            this.itemsX.push(obj)
        }
        for (let j = 0; j < y; j++) {
            obj = {
                index: j,
                rotateY: rotateX * j
            };
            this.itemsY.push(obj);
        }
    }
}
